using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Comteck.Dto.Orders;

namespace Comteck.Ktt.Services.Orders {
  /// <summary>
  /// 
  /// </summary>
  public interface ISaleOrderService : IScopedDependency {
    /// <summary>
    /// 更新订单
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderDto>> UpdateAsync(SaleOrderDto model);

    /// <summary>
    /// 查询分页主表数据
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    Task<AjaxResponsePage<List<SaleOrderDto>>> GetPageListAsync(SaleOrderQuery model);

    /// <summary>
    /// 商品订单明细
    /// </summary>
    /// <param name="orderId"></param>
    /// <returns></returns>
    Task<IEnumerable<SaleOrderDetailDto>> GetDetailListByOrderIdAsync(string orderId);

    /// <summary>
    /// 订单轨迹明细
    /// </summary>
    /// <param name="orderId"></param>
    /// <returns></returns>
    Task<IEnumerable<SaleOrderPathDto>> GetPathListByOrderIdAsync(string orderId);

    /// <summary>
    /// 转换excel
    /// </summary>
    /// <param name="table"></param>
    /// <returns></returns>
    Task<List<SaleOrderExcelDto>> ChangeExcelDataAsync(DataTable table);

    /// <summary>
    /// 填充商品重量信息
    /// </summary>
    /// <param name="list"></param>
    /// <returns></returns>
    Task<List<SaleOrderExcelDto>> FillProductInfoForExcelDataAsync(List<SaleOrderExcelDto> list);

    /// <summary>
    /// 保存多个对象
    /// </summary>
    /// <param name="modelList"></param>
    /// <param name="user"></param>
    /// <returns></returns>
    Task<List<SaleOrderDto>> SaveExcelDataAsync(List<SaleOrderExcelDto> modelList);

    /// <summary>
    /// 批量删除订单
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task DeleteBatchAsync(List<string> ids);

    /// <summary>
    /// 批量审核
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> AuditBatchAsync(List<string> ids);

    /// <summary>
    /// 批量强制审核
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> ForceAuditBatchAsync(List<string> ids);

    /// <summary>
    /// 批量反审核
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> UnAuditBatchAsync(List<string> ids);

    /// <summary>
    /// 将多个商品拆分到新订单上
    /// </summary>
    /// <param name="orderId"></param>
    /// <param name="detailIds"></param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderSplitGoods2NewOrder>> SplitGoods2NewOrderAsync(string orderId, List<string> detailIds);

    /// <summary>
    /// 把订单明细商品拆分成多个订单
    /// </summary>
    /// <param name="detailId"></param>
    /// <param name="newQty">每份数量</param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> SplitOrderDetailAsync(string orderId, string detailId, int newQty);

    /// <summary>
    /// 将已拆单的订单全部合并回来
    /// </summary>
    /// <param name="orderId"></param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderUnSplitDto>> CombineOrderAsync(string orderId);

    /// <summary>
    /// 获取运单号
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderDto>> GetWaybillNoAsync(string id);

    /// <summary>
    /// 获取运单号轨迹
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderDto>> GetWaybillNoPathAsync(string id);

    /// <summary>
    /// 取消运单号
    /// </summary>
    /// <param name="id"></param>
    /// <param name="cancelReason"></param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderDto>> CancelWaybillNoAsync(string id, string cancelReason);

    /// <summary>
    /// 商品id是否被使用了
    /// </summary>
    /// <param name="productId"></param>
    /// <returns></returns>
    Task<bool> IsProductUserdAsync(int productId);

    /// <summary>
    /// 自提点是否被使用了
    /// </summary>
    /// <param name="selfOrgId"></param>
    /// <returns></returns>
    Task<bool> IsSelfOrgUsedAsync(int selfOrgId);

    /// <summary>
    /// 批量反打印
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> UnPrintBatchAsync(List<string> ids);

    /// <summary>
    /// 放入回收站
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> RecycleBatchAsync(List<string> ids);

    /// <summary>
    /// 移出回收站
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<AjaxResponse<List<SaleOrderDto>>> UnRecycleBatchAsync(List<string> ids);

    /// <summary>
    /// 重刷商品重量
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<List<SaleOrderDto>> RefreshWeightAsync(List<string> ids);

    /// <summary>
    /// 打印完毕后更新状态及数量
    /// </summary>
    /// <param name="ids"></param>
    /// <returns></returns>
    Task<List<SaleOrderDto>> UpdateStatusAfterPrintAsync(List<string> ids);

    /// <summary>
    /// 查找可合并的订单
    /// </summary>
    /// <returns></returns>
    Task<List<SaleOrderDto>> FindMergeableOrdersAsync();

    /// <summary>
    /// 合并订单
    /// </summary>
    /// <param name="orderIds">要合并的订单ID列表</param>
    /// <returns></returns>
    Task<AjaxResponse<SaleOrderDto>> MergeOrdersAsync(List<string> orderIds);
  }
}
